<template>
  <h2>依赖注入 - {{ count }} - <button @click="add">btn</button></h2>
  <ChildIndex9 />
</template>

<script>
import ChildIndex9 from "../components/ChildIndex9.vue";
import { provide, ref } from "vue";
export default {
  components: {
    ChildIndex9,
  },
  setup() {
    // provide调用，里面是两个参数
    // vue3的依赖注入是具有响应式的
    provide("msg", "hello");

    const count = ref(1);
    const add = () => {
      count.value++;
    };
    provide("count", count);

    return {
      count,
      add,
    };
  },
};
</script>
